
const Ioredis = require('ioredis')
const logger = require('util/logger')
const config = require('@config/config')

const redis = new Ioredis(config.redis)

/**
 * redis监控日志
 */
redis.on('connect', function () {
    logger.getLogger('default').trace('redis', '连接成功')
    // console.log('redis connect success')
})

redis.on('error', function () {
    logger.getLogger('error').fatal('redis', '连接失败')
    // console.log('redis connect error')
})

redis.on('reconnecting', function () {
    logger.getLogger('error').warn('redis', '尝试重新连接中')
    // console.log('redis connect reconnecting')
})
 
module.exports = redis
